home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98a.txt / 000139_icon-group-sender _Mon Mar 16 16:21:26 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id QAA21320
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Mon, 16 Mar 1998 16:21:26 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA12573; Mon, 16 Mar 1998 16:21:25 -0700
  7. Message-Id: <350DA0F2.6075@gte.net>
  8. Date: Mon, 16 Mar 1998 16:00:18 -0600
  9. From: Mark Evans <evans@gte.net>
  10. Reply-To: evans@gte.net
  11. Organization: None
  12. X-Mailer: Mozilla 3.01 (Win95; I)
  13. Mime-Version: 1.0
  14. To: icon-group@optima.CS.Arizona.EDU
  15. Cc: evans@gte.net
  16. Subject: Re: image
  17. References: <199803140354.VAA03466@axp.cmpu.net> <350D49AD.3539@gte.net>
  18. Content-Type: text/plain; charset=us-ascii
  19. Content-Transfer-Encoding: 7bit
  20. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  21. Status: RO
  22. Content-Length: 1305
  23.  
  24. I can answer my own question.  The function 'escape' that is linked by
  25. xcode essentially reverses an image() call.
  26.  
  27. As for the high ASCII characters, here is a little utility routine that
  28. does the job, but I would much rather have a library call for this.
  29.  
  30. Mark
  31.  
  32.  
  33. ____________________________
  34.  
  35.  
  36.  
  37.  
  38. link xcode
  39.  
  40. global diagnose
  41.  
  42. procedure main(av)
  43.  
  44.    diagnose := open("diagnose.txt","w")
  45.    write(diagnose,image_NotHighChars("\n\r\tABCDEF\xde|K!\\"))
  46.    write(diagnose,"\n\n\n")
  47.    close(diagnose)
  48.  
  49. end
  50.  
  51.  
  52.  
  53. procedure image_NotHighChars(str)
  54.  
  55.    # lets you print chars native that are ASCII > 128
  56.    # Icon's "image" routine gives nasty hex escape codes for these
  57.  
  58.    local img_str,new_str,esc_seq
  59.  
  60.    img_str := image(str)
  61.    write(diagnose,"img_str is -->",img_str,"<---")
  62.    
  63.    new_str := ""
  64.  
  65.    img_str ?
  66.    {
  67.       while new_str ||:= tab(upto('\\')) do
  68.       {
  69.          write(diagnose,"new_str is -->",new_str,"<---")
  70.          esc_seq := move(2)
  71.          write(diagnose,"esc_seq is -->",esc_seq,"<---")
  72.          if (esc_seq) == "\\x" then # hexadecimal ASCII code
  73.          {
  74.             new_str ||:= escape(esc_seq ||:= move(2))
  75.          }
  76.          else
  77.          {
  78.             new_str ||:= esc_seq
  79.          }
  80.       }
  81.       new_str ||:= tab(0)  # anything after last esc seq
  82.    }
  83.    return new_str
  84. end
  85.  
  86.